<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<html>
<head>
    <meta charset="UTF-8">
    <title>...</title>
    <script src="webjars/jquery/3.6.0/dist/jquery.min.js"></script>
    <link rel="stylesheet" href="webjars/bootstrap/3.4.1/css/bootstrap.min.css">
    <script src="webjars/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        table{
            border: 1px solid black;
            border-collapse:separate;
            border-spacing: 2px;
            text-align: center;
        }
        td{
            border:1px solid black;
            width: 200px;
        }
        .td1{
            text-align: left;
        }
        #compName{
            margin-right:50px;
        }
        #ownerName{
            margin-right:50px;
        }
        label{
            margin-left: 20px;
        }
        #visit{
            display: block;
        }
    </style>
</head>
<body>
    <table>
        <tr><td colspan="6">客户资料信息列表</td></tr>
        <tr>
            <td colspan="6" class="td1">
                <button id="add">添加回访记录</button>
                <label for="compName">公司名称:</label><input type="text" id="compName" class="text">
                <label for="ownerName">法人姓名:</label><input type="text" id="ownerName" class="text">
                <button id="search" onclick="selectByName()">查询</button>
            </td>
        </tr>
        <tr>
            <td>选择</td>
            <td>公司名称</td>
            <td>法人名称</td>
            <td>联系电话</td>
            <td>公司简介</td>
            <td>操作</td>
        </tr>
        <tbody id="tb"> </tbody>
    </table>
        <form action="#" id="visit">
        <table>
            <tr>
                <td colspan="4" align="left"><b>添加客户回访</b></td>
                <td></td>
            </tr>
            <tr>
                <td>回访姓名：</td>
                <td><input type="text"></td>
                <td>回访时间：</td>
                <td><input type="text"></td>
                <td></td>
            </tr>
            <tr>
                <td>回访类型：</td>
                <td>
                    <select name="visitType" id="visitType">
                        <option value="售后回访">售后回访</option>
                        <option value="销售意向回访">销售意向回访</option>
                        <option value="满意度回访">满意度回访</option>
                    </select>
                </td>
                <td>回访方式：</td>
                <td>
                    <select name="" id="">

                    </select>
                </td>
                <td></td>
            </tr>
            <tr>
                <td>回访结果：</td>
                <td colspan="4" align="left">
                <textarea>
                </textarea>
                </td>
            </tr>
            <tr>
                <td colspan="5">
                    <button type="button">提交</button>
                    <button type="reset">重置</button>
                </td>
            </tr>
        </table>
        </form>

</body>
</html>
<script>
    $(function () {
        getAll();
    })
    function getAll() {
        $.get("/getAll.do",function (data) {
            $("#tb").html("");
            let str = "";
            console.log("data:",data);
            data.forEach(comp=>{
                str += "<tr>";
                str += "<td><input type='radio' name='xz' value='"+comp.cid+"'></td>";
                str += "<td>" + comp.compName + "</td>";
                str += "<td>" + comp.ownerName + "</td>";
                str += "<td>" + comp.ownerTel + "</td>";
                str += "<td>" + comp.compInfo + "</td>";
                str += "<td>";
                str += "<a href='#' onclick='getTelVisit()'>查看所有回访</a>";
                str += "</td>";
                str += "</tr>";
            })
            $("#tb").html(str);
        },"json");
    }

    function selectByName() {
        let compName = $("#compName").val();
        let ownerName = $("#ownerName").val();
        $.get("/getAllByName.do?compName="+compName+"&ownerName="+ownerName,function (data) {
            $("#tb").html("");
            let str = "";
            console.log("data:",data);
            data.forEach(comp=>{
                str += "<tr>";
                str += "<td><input type='radio' name='xz' value='"+comp.cid+"'></td>";
                str += "<td>" + comp.compName + "</td>";
                str += "<td>" + comp.ownerName + "</td>";
                str += "<td>" + comp.ownerTel + "</td>";
                str += "<td>" + comp.compInfo + "</td>";
                str += "<td>";
                str += "<a href='#' onclick='getTelVisit()'>查看所有回访</a>";
                str += "</td>";
                str += "</tr>";
            })
            $("#tb").html(str);
        },"json");
    }
</script>